package br.com.scitv;

import java.io.FileInputStream;
import java.util.Properties;

import xjavax.tv.xlet.Xlet;
import xjavax.tv.xlet.XletContext;
import xjavax.tv.xlet.XletStateChangeException;
import br.com.scitv.action.SCITVAction;


public class SCITV implements Xlet{
	private static Properties properties;
	public static String BASEDIR  = "../scitv/";
	private XletContext context;
	private SCITVAction scitaction;

	public void initXlet(XletContext ctx) throws XletStateChangeException {
		System.out.println("SCITV.initXlet()");
		context = ctx;
		properties = new Properties();
		try {  
			properties.load( new FileInputStream("../" + "scitv.properties" ) );  
		} catch (Exception ex) {  
			ex.printStackTrace();  
		}
		scitaction = new SCITVAction(); 
	}

	public void startXlet() throws XletStateChangeException {
		System.out.println("SCITV.startXlet()");
		
		scitaction.iniciar();
	}

	public void pauseXlet() {
		System.out.println("SCITV.pauseXlet()");
	}

	public void destroyXlet(boolean unconditional)
			throws XletStateChangeException {
		System.out.println("SCITV.destroyXlet()");
		
		
		context.notifyDestroyed();
	}
	
	public static String getPropiedade(String chave)
	{
		return properties.getProperty(chave);
	}
	
	public static String getPropiedadePathImagem(String chave)
	{
		return BASEDIR + properties.getProperty(chave);
	}
}
